<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.util.*,com.gj.dao.*,com.gj.daoImp.*,com.gj.bean.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head> 
<link href="../css/style.css" type="text/css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

</head>
<body>
	 <%
	 ArrayList<CategoryBean> categorys1=new ArrayList<CategoryBean>();
	 ArrayList<CategoryBean> categorys=new ArrayList<CategoryBean>();
	 ArrayList<ContactsBean> contacts=new ArrayList<ContactsBean>();
	int contactId=Integer.parseInt(request.getParameter("contactId"));
	 CategoryDao category=new CategoryDaoImp();
	 ContactDao contact=new ContactDaoImp();
	 contacts=contact.getContactInfoId(contactId);
	 categorys=category.GetContegoryInfoById(contactId);
	 categorys1=category.GetCategoryInfo();
	
	 %>
	<script type="text/javascript">
	  function onlyR(){
		var save=document.getElementById("save");
		 save.style.display = "block";
		var obj=document.getElementsByTagName("input");
		for(var i=0;i<obj.length;i++){
		if (i ==obj.length-1)
		{
			obj[i].readOnly=true; 
		}
		obj[i].readOnly=false; 
		
		}
		document.getElementById("btnUpdate").readOnly=true;
		var update=document.getElementById("btnUpdate").value='清空';
		document.getElementById("btnUpdate").onclick=function(){
				document.getElementById("username").value="";
				document.getElementById("telephone").value="";
				document.getElementById("mark").value="";
				document.getElementById("address").value="";
			
		}
		
		document.getElementById("category").style.display="none";
		document.getElementById("select").style.display="block";
		
	  }
	</script>
	<div class="context">
		<h3 >联系人详情</h3>
	<div>
	<form action="ContactServlet" method="post"  >
		<div class="top1">姓名:<input type="text" name="username" id="username" style="height: 25px; width: 250px" value=<%=contacts.get(0).getContactName() %> readonly="readonly"></div>
		<div class="top1">电话:<input type="text" name="telephone" id="telephone" style="height: 25px; width: 250px;margin-left: 5px"value=<%=contacts.get(0).getContectNum()%> readonly="readonly" ></div>
		<div class="top1">备注:<input type="text" name="mark" id="mark" style="height: 25px; width: 250px"value=<%=contacts.get(0).getMark() %> readonly="readonly"></div>
		<div class="top1">地址:<input type="text" name="address" id="address" style="height: 25px; width: 250px;margin-left:5px" value=<%=contacts.get(0).getAddress()%> readonly="readonly"/></div>
		<div id="category" class="top1">分类:<input type="text" name="relation" id="relation" style="height: 25px; width: 250px" value=<%=categorys.get(0).getCategoryName()%> readonly="readonly"></div>
		<input name=contactId type="hidden" value=<%=contactId %>>
		<input name=type type="hidden" value="update">
		<input name=categoryId type="hidden" value=<%=contacts.get(0).getCategoryId() %>>
		<div id="select"  style="display: none;margin-left: -15px;margin-top: 5px">
		 分类：<select name="selectName" id="selectName" style="width: 260px;height: 30px" >
		 <%for(int i=0;i<categorys1.size();i++){%>
       	 <option value=<%=categorys1.get(i).getCategoryId() %>><%=categorys1.get(i).getCategoryName() %></option >
       	 <% } %>
      </select>
    </div>	
		<div style="margin-left:200px">
			 <input class="btn" type="button" name="btnUpdate" id="btnUpdate" value="修改" onclick="onlyR()">
			 <input type="submit" class="btn" name="btnSave" id="save" value="保存" style="display:none;">
		</div>
	</form>
	</div>
	</div>
</body>
</html>